﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Configuration;
using System.Web;
using System.IO;
using System.Web.Routing;
using System.Web.Configuration;


namespace DALSingTowerMall
{
    public class MallInfoDAO
    {
        XmlDocument shoppingmalldoc;

        public MallInfoDAO(string xmlfilepath)
        {
            shoppingmalldoc = new XmlDocument();
            shoppingmalldoc.Load(xmlfilepath);
        }


        public MallInfo getMallInfo()
        {
            MallInfo mallInfo = new MallInfo();
            List<string> images = new List<string>();

            XmlNode name = shoppingmalldoc.SelectSingleNode("ShoppingMall/Name");
            mallInfo.Name = name.InnerText;
            XmlNode mallDesc = shoppingmalldoc.SelectSingleNode("ShoppingMall/MallDesc");
            mallInfo.Malldesc = mallDesc.InnerText;
            XmlNodeList imagesList = shoppingmalldoc.SelectNodes("ShoppingMall/MallImagesUrl/MallImageUrl");
            foreach (XmlNode image in imagesList)
                images.Add(image.InnerText);
            mallInfo.MallImages = images.ToArray();
            XmlNode copyrightInfo = shoppingmalldoc.SelectSingleNode("ShoppingMall/CopyRightInfo");
            mallInfo.Copyrightinfo = copyrightInfo.InnerText;
            XmlNode address = shoppingmalldoc.SelectSingleNode("ShoppingMall/Address");
            mallInfo.Address = address.InnerText;
            XmlNode contactNo = shoppingmalldoc.SelectSingleNode("ShoppingMall/ContactNo");
            mallInfo.ContactNo = contactNo.InnerText;
            return mallInfo;
        }
    }
}
